from PyQt4 import QtCore, QtGui;

class ContextMenuCmds(QtCore.QObject):
    def __init__(self, parentView, graphScene, actCmds):
        super(ContextMenuCmds, self).__init__();
        self.parentView = parentView;
        self.graphScene = graphScene;
        self.actionCmds = actCmds;
        self.createContextMenuCmds();
        
    
    def createContextMenuCmds(self):
        self.contextMenu = QtGui.QMenu(self.parentView);
        self.menuSelect = QtGui.QMenu("Select", self.contextMenu);        
        self.menuShowInfo = QtGui.QMenu("Show Info Style", self.contextMenu);
        self.menuStateInfo = QtGui.QMenu("State", self.contextMenu);
        self.menuEdgeInfo = QtGui.QMenu("Edge", self.contextMenu);
        self.menuActionInfo = QtGui.QMenu("Action", self.contextMenu);
        self.menuStatusType = QtGui.QMenu("Status Type", self.contextMenu);
        self.menuSt_StatusType = QtGui.QMenu("State", self.contextMenu);
        self.menuAct_StatusType = QtGui.QMenu("Action", self.contextMenu);
        self.menuGraphSettings = QtGui.QMenu("Set Graph Settings", self.contextMenu);
        self.menuAlignNodes = QtGui.QMenu("Align State Nodes", self.contextMenu);
        self.menuBuildGraph = QtGui.QMenu("Build Graph from...", self.contextMenu);
        self.menuBuildGraph.setIcon(QtGui.QIcon('Images/buildGraph.png'));
        self.menuGenerateTable = QtGui.QMenu("Generate tables...", self.contextMenu);
        self.menuStBkgColor = QtGui.QMenu("States Background Color", self.menuGraphSettings);
        self.menuActBkgColor = QtGui.QMenu("Actions Background Color", self.menuGraphSettings);
        self.menuGenerateTable.setIcon(QtGui.QIcon('Images/build_Tables.png'));
        
        #Edit
#        self.contextMenu.addAction(self.actionCmds.actionEditNodeInfo);
#        self.contextMenu.addAction(self.actionCmds.actionEditEdgeInfo);
        self.contextMenu.addAction(self.actionCmds.actionAddNode);
        self.contextMenu.addAction(self.actionCmds.actionDelete);
        self.contextMenu.addAction(self.actionCmds.actionAddCtrlPt);
        self.contextMenu.addAction(self.actionCmds.actionShowCtrlPts);
        self.contextMenu.addSeparator();
        
        #Set General Settings                
#        self.menuGraphSettings.addAction(self.actionCmds.actionMovable);
#        self.menuGraphSettings.addAction(self.actionCmds.actionSelectable);
#        self.menuStBkgColor.addAction(self.actionCmds.actionStBkgColor_None);
#        self.menuStBkgColor.addAction(self.actionCmds.actionStBkgColor_ByVal);
#        self.menuStBkgColor.addAction(self.actionCmds.actionStBkgColor_ByR);
#        self.menuStBkgColor.addAction(self.actionCmds.actionStBkgColor_ByDim);
#        self.menuActBkgColor.addAction(self.actionCmds.actionActBkgColor_None);
#        self.menuActBkgColor.addAction(self.actionCmds.actionActBkgColor_ByQ);
#        self.menuGraphSettings.addAction(self.actionCmds.actionActsFront);
#        self.menuGraphSettings.addAction(self.actionCmds.actionEdgesFront);
#        self.menuGraphSettings.addAction(self.actionCmds.actionHideActs);
#        self.menuGraphSettings.addAction(self.actionCmds.actionHideEdges);
#        self.menuGraphSettings.addAction(self.menuStBkgColor.menuAction());
#        self.menuGraphSettings.addAction(self.menuActBkgColor.menuAction());
#        self.contextMenu.addAction(self.menuGraphSettings.menuAction());
        
        #Select
        self.menuSelect.addAction(self.actionCmds.actionSelectGraph);
        self.menuSelect.addAction(self.actionCmds.actionSelectNodes);
#        self.menuSelect.addAction(self.actionCmds.actionSelectNodesByDim);
        self.menuSelect.addAction(self.actionCmds.actionSelectActions);
        self.menuSelect.addAction(self.actionCmds.actionSelectEdges);
        self.contextMenu.addAction(self.menuSelect.menuAction());
        
        #Align Nodes
        self.menuAlignNodes.addAction(self.actionCmds.actionAlign_Left);
        self.menuAlignNodes.addAction(self.actionCmds.actionAlign_Right);
        self.menuAlignNodes.addAction(self.actionCmds.actionAlign_CenterH);
        self.menuAlignNodes.addAction(self.actionCmds.actionAlign_CenterV);
        self.menuAlignNodes.addAction(self.actionCmds.actionAlign_Top);
        self.menuAlignNodes.addAction(self.actionCmds.actionAlign_Bottom);
        self.contextMenu.addAction(self.menuAlignNodes.menuAction());
        self.contextMenu.addSeparator();
        
        #Graph Info Style
#        self.menuStateInfo.addAction(self.actionCmds.actionSt_AllInfo);
#        self.menuStateInfo.addAction(self.actionCmds.actionSt_HideV);
#        self.menuStateInfo.addAction(self.actionCmds.actionSt_HideR);
#        self.menuStateInfo.addAction(self.actionCmds.actionSt_OnlyR);
#        self.menuStateInfo.addAction(self.actionCmds.actionSt_OnlyV);
#        self.menuStateInfo.addAction(self.actionCmds.actionSt_OnlyDim);
#        self.menuStateInfo.addAction(self.actionCmds.actionSt_NoInfo);
#        self.menuEdgeInfo.addAction(self.actionCmds.actionEdge_AllInfo);
#        self.menuEdgeInfo.addAction(self.actionCmds.actionEdge_OnlyProb);
#        self.menuEdgeInfo.addAction(self.actionCmds.actionEdge_OnlyR);
#        self.menuEdgeInfo.addAction(self.actionCmds.actionEdge_NoInfo);
#        self.menuActionInfo.addAction(self.actionCmds.actionAct_OnlyQ);
#        self.menuActionInfo.addAction(self.actionCmds.actionAct_OnlyId);
#        self.menuActionInfo.addAction(self.actionCmds.actionAct_NoInfo);
#        self.menuShowInfo.addAction(self.menuStateInfo.menuAction());
#        self.menuShowInfo.addAction(self.menuEdgeInfo.menuAction());
#        self.menuShowInfo.addAction(self.menuActionInfo.menuAction());
#        self.contextMenu.addAction(self.menuShowInfo.menuAction());
        
        #Graph Status Type        
#        self.menuSt_StatusType.addAction(self.actionCmds.actionSt_Normal);
#        self.menuSt_StatusType.addAction(self.actionCmds.actionSt_Current);
#        self.menuSt_StatusType.addAction(self.actionCmds.actionSt_Goal);
#        self.menuSt_StatusType.addAction(self.actionCmds.actionSt_Fatal);
#        self.menuAct_StatusType.addAction(self.actionCmds.actionAct_Normal);
#        self.menuAct_StatusType.addAction(self.actionCmds.actionAct_Current);
#        self.menuAct_StatusType.addAction(self.actionCmds.actionAct_Best);
#        self.menuAct_StatusType.addAction(self.actionCmds.actionAct_Risky);
#        self.menuStatusType.addAction(self.menuSt_StatusType.menuAction());
#        self.menuStatusType.addAction(self.menuAct_StatusType.menuAction());
#        self.contextMenu.addAction(self.menuStatusType.menuAction());
        self.contextMenu.addSeparator();
        
        #Build Graph (from Tables)
        self.menuBuildGraph.addAction(self.actionCmds.actionBuildGraph_AllTables);
        self.menuBuildGraph.addAction(self.actionCmds.actionBuildGraph_Transition);
        self.menuBuildGraph.addAction(self.actionCmds.actionBuildGraph_StateDim);
        self.menuBuildGraph.addAction(self.actionCmds.actionBuildGraph_StateInfo);
        self.menuBuildGraph.addAction(self.actionCmds.actionBuildGraph_Rewards);
        self.menuBuildGraph.addAction(self.actionCmds.actionBuildGraph_QValue);
        self.menuGenerateTable.addAction(self.actionCmds.actionGenerateTable_AllTables);
        self.menuGenerateTable.addAction(self.actionCmds.actionGenerateTable_Transition);
        self.menuGenerateTable.addAction(self.actionCmds.actionGenerateTable_StateDim);
        self.menuGenerateTable.addAction(self.actionCmds.actionGenerateTable_StateInfo);
        self.menuGenerateTable.addAction(self.actionCmds.actionGenerateTable_Rewards );
        self.menuGenerateTable.addAction(self.actionCmds.actionGenerateTable_QValue);
        self.contextMenu.addAction(self.menuBuildGraph.menuAction());
        self.contextMenu.addAction(self.menuGenerateTable.menuAction());
        